package br.com.puertorico.model.querybuilder.sorting;

/**
 *
 * @author Daniel Camargo
 * @version 1.0.0
 */
public class SingleSortStrategy extends SortStrategy {

	private static final long serialVersionUID = -728376695636905859L;

	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * br.ufms.nin.jpa.querybuilder.api.SortStrategie#addSortItem(java
	 * .lang.String)
	 */
	@Override
	public void addSortItem(String columnName) {
		// contem no map
		if (getSortItemMap().containsKey(columnName)) {
			if (getSortItemMap().get(columnName).getAsc()) {
				getSortItemMap().get(columnName).setAsc(false);
			} else {
				getSortItemMap().remove(columnName);
			}
		} else {
			getSortItemMap().clear();
			getSortItemMap().put(columnName, new SortItem(columnName, true, 0));
		}
	}

}
